package practica02;

import java.util.Arrays;
import java.util.LinkedList;
import javax.swing.*;

public class Eje09 {
	private static LinkedList<Integer> l = new LinkedList<Integer>();
	public static void main(String[] args) {
		int opc;
		
		do
		{
			opc = Ingreso();
		}while(opc==0);
		Object[] larray = l.toArray();
		Arrays.sort(larray);
		StringBuilder texto = new StringBuilder();
		
		for (Object o : larray) {
			texto.append(o.toString() + "\n");
		}
		
		JOptionPane .showMessageDialog(null, texto.toString(), "Resultado", JOptionPane .PLAIN_MESSAGE);
	}
	
	public static int Ingreso()
	{
		int a;
		int opc;
		
		do
		{
			try
			{				
				a=Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese un numero\n[Cancelar no implementado]", "Ingreso", JOptionPane.NO_OPTION));
			}
			catch(Exception ex)
			{
				a=-1;
			}
		}while(a<0);
		l.add(a);
		opc=JOptionPane.showConfirmDialog(null, "Desea continuar", "Pregunta", JOptionPane.YES_NO_OPTION);
		return opc;
	}

}
